Ext.require([
    'Ext.window.*',
    'Ext.layout.container.Border'
]);
var processWin;
Ext.onReady(function(){
	 var form = new Ext.form.Panel({
	        border: false,
	        fieldDefaults: {
	            labelWidth: 60
	        },
	        defaultType: 'textfield',
	        items: [{
	        	style :"margin-top:10px;margin-left:6px;",
	            fieldLabel: '名字',
	            id:'name',
	            name: 'name',
	            anchor:'80%'  // anchor width by percentage
	        },{
	        	style :"margin-left:6px;",
	            fieldLabel: 'key',
	            name: 'processKey',
	            id:'processKey',
	            anchor: '80%'  // anchor width by percentage
	        }, {
	            xtype: 'textarea',
	            hideLabel: true,
	            name: 'remark',
	            anchor: '100% -'  // anchor width by percentage and height by raw adjustment
	        }]
	    });
    if (!processWin) {
    	processWin = Ext.create('widget.window', {
    		title: '添加一个流程',
	        width: 300,
	        height:200,
	        minWidth: 300,
	        xtype:'window',
	        id:'processWin',
	        minHeight: 200,
	        layout: 'fit',
	        modal: true,
	        plain: true,
	        items: form,
	        closeAction:'hidden',
	        buttons: [{
	            text: '提交',
	            type : 'submit',
				style:'width:20px;',
				// 定义表单提交事件
				handler : function(){
					// 提交到服务器操作
					form.form.doAction('submit', {
								url : 'addProcess.do',// 路径
								method : 'post',// 提交方法post或get
								params : '',
								// 提交成功的回调函数
								success : function(form, action) {
									if (action.result.success == 'true') {
										alert("suc");
									} else {
										Ext.Msg.alert('登陆错误',
												action.result.msg);
									}
								},
								//提交失败的回调函数
								failure : function() {
									Ext.Msg.alert('错误', '服务器出现错误请稍后再试！');
								}
							});
				}
	        },{
	            text: '取消',
	            handler : function(){
	            	processWin.hide();
	            }
	        }],
	        listeners:{
	        	"close":function(){
	        		alert("关闭窗口");
	        	}
	        }
    	});
    }else{
    	processWin.show(this);
    }
});